import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.TextField;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class LoginSystem {
    public static void main(String[] args) {
        final TextField tf_pass;
        final TextField tf_name;
        JFrame f=new JFrame();
        f.setVisible(true);
        f.setSize(400,400);

        f.setLocationRelativeTo(null);
        f.setTitle("用户登录界面");

        Container con=f.getContentPane();
        con.setLayout(new GridLayout(5,1));

        JPanel pan1=new JPanel();
        Icon pic=new ImageIcon("E:\\360MoveData\\Users\\26542\\Desktop\\1-2012221T114.jpg");
        JLabel J_pic=new JLabel(pic);
        pan1.add(J_pic);
        con.add(pan1);

        JPanel pan2=new JPanel();
        JLabel title=new JLabel("欢迎登录");
        title.setFont(new Font("宋体",Font.BOLD,20));
        pan2.add(title);
        con.add(pan2);

        JPanel pan3=new JPanel();
        JLabel name=new JLabel("用户名：");
        tf_name=new TextField(20);
        tf_name.setText("请在此处输入用户名");
        pan3.add(name);pan3.add(tf_name);
        con.add(pan3);

        JPanel pan4=new JPanel();
        JLabel pass=new JLabel("密	码：");
        tf_pass=new TextField(20);
        tf_pass.setText("请在此处输入密码");
        pan4.add(pass);pan4.add(tf_pass);
        con.add(pan4);

        JPanel pan5=new JPanel();
        JButton b_log=new JButton("登录");
        b_log.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                String user_pass=tf_pass.getText();
                String user_name=tf_name.getText();
                if(user_name.equals("张帆")&&user_pass.equals("987654321")){
                    JOptionPane.showMessageDialog(null, "登录成功");
                    new GuessNumber();
                }
                else
                    JOptionPane.showMessageDialog(null, "用户或密码错误，登录失败！");
            }
        });
        JButton b_exit=new JButton("退出");
        b_exit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                System.exit(0);
            }
        });
        pan5.add(b_log);pan5.add(b_exit);
        con.add(pan5);
    }
}
